<?php
$data = '"{\"buff\":{\"1003\":{\"buff_sn\":12001,\"endtime\":34869},\"1001\":{\"buff_sn\":12001,\"endtime\":34869},\"1004\":{\"buff_sn\":12001,\"endtime\":34869},\"2001\":{\"buff_sn\":10301,\"endtime\":34869},\"3001\":{\"buff_sn\":10001,\"endtime\":34869,\"start_time\":1680537600,\"end_time\":1700668800},\"1002\":{\"buff_sn\":12001,\"endtime\":34869}},\"free_buff_num\":100,\"buy_buff_cost\":10,\"start_time\":1680516000,\"end_time\":1650643200,\"deafult_lvl\":\"6\",\"mystery_times\":50,\"origin_open_yn\":1}"';


$data = json_decode($data, true);
$data = json_decode($data, true);
//var_dump($data);


View::display($data, 'dump');

class View
{
    /**
     * 打印
     * @param mixed $msg 数据
     */
    static function dump($msg)
    {
        $str = json_encode($msg, 384);
        return array($str, 'application/json');
    }

    /**
     * json输出
     * @param array $arr 数组
     * @return array
     */
    static function json($arr)
    {
        $str = json_encode($arr, 256);
        return array($str, 'application/json');
    }

    static function display($data, $format = 'json', $tpl = '')
    {
      if ('jsonp' == $format) {
        $json = json_encode($data);
        $out = array(getCgi('cb', 'cb') . "($json);", 'application/x-javascript');
      } else{
         method_exists('View', $format) && $out = View::$format($data);
      }
      headers_sent() || header('Content-type:' . $out[1] . ';charset=UTF-8;');
      echo $out[0];
    }
}